<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
</head>

<body>
    <button>get</button>
    <button>post</button>
    <button>jsonp</button>
</body>
<script>
    $("button").eq(0).click(function () {
        $.ajax({
            type: "get",
            url: "http://192.168.57.165/2207_php/demo_30_async/php/searchGradeOrderLimit.php",
            data: {
                wd: "",
                col: "id",
                type: "asc",
                page: 1,
                size: 10,
            },
            dataType: "json",
            success: function (data) {
                console.log(data);
            }
        })
        $.get("http://192.168.57.165/2207_php/demo_30_async/php/searchGradeOrderLimit.php", {
            wd: "",
            col: "id",
            type: "asc",
            page: 1,
            size: 10,
        }, function (data) {
            console.log(data);
        }, "json")
    })


    $("button").eq(1).click(function () {
        $.ajax({
            type: "post",
            url: "http://192.168.57.165/2207_php/demo_30_async/php/login.php",
            data: {
                user: "a123123",
                pwd: 123123,
            },
            dataType: "json",
            success: function (data) {
                console.log(data);
            }
        })
        // $.post("http://192.168.57.165/2207_php/demo_30_async/php/login.php", {
        //     user: "a123123",
        //     pwd: 123123,
        // }, function (data) {
        //     console.log(data);
        // }, "json")
    })

    $("button").eq(2).click(function () {
        // jsonp
        $.ajax({
            type: "get",
            url: "http://192.168.57.165/2207_php/jsonp/searchGradeOrderLimitCallback.php",
            data: {
                wd: "",
                col: "id",
                type: "asc",
                page: 1,
                size: 10,
            },
            dataType: "jsonp", // 以jsonp的形式创建请求
            jsonp: "cb", // 接收回调函数字段名 (默认callback => callback=xxx)
            jsonpCallback: "fn",  // 回调函数名(默认随机生成 jQuery456665132132)
            success: function (data) {
                console.log(data);
            },
            error: function (err) {
                console.log(err);
            }
        })

        $.getJSON("http://192.168.57.165/2207_php/jsonp/searchGradeOrderLimitCallback.php?cb=?", {
            wd: "",
            col: "id",
            type: "asc",
            page: 1,
            size: 10,
        }, function (data) {
            console.log(data);
        })
    })




</script>

</html>